/*
 * Util.h
 *
 *  Created on: 2013. 7. 29.
 *      Author: ncanis
 */
#pragma once

#include "stdafx.h"
//#include <atlstr.h> // CString
#include "Util.h"

using namespace std;
namespace TED {

enum LogLevel {
	Debug, Info, Warn, Error
};

/**
	@author ncanis
	@brief 로그 클래스
*/
class Logger {

private:
	Logger(){}
	~Logger() {}
	void Log(const TCHAR* format, va_list ap);

public:
	 static Logger& Get() {
		 static CriticalSectionManager lock;
		 // 멀티스레드로 인한 다중 생성을 막기위해 필요하다.
		 lock.EnterLock();

		 static Logger* instance;
		 if(instance==NULL) {			 
			 instance = new Logger();
		 }
		 lock.LeaveLock();
		 return *instance;
	 }
	 void Debug(const TCHAR* format, ...);
	 void ErrorSocket(const TCHAR* format, ...);
	 void ErrorSocket(const INT32 code, const TCHAR* format, ...);
};

//// static 변수에 대한 초기화
//// need to actually allocate the static member somewhere ( if not  undefined reference to ... compile error)
//bool Logger::destroyed = false;
//Logger* Logger::instance = NULL;

}
